package com.avfh.netcard.listener;

import com.avfh.netcard.common.Constant;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;


/**
 * 公众号初始化配置
 *
 * @author wh
 */
@Service
public class StartupListener implements ApplicationListener<ContextRefreshedEvent> {

    public static WxMpServiceImpl wxService;

    public static WxMpInMemoryConfigStorage wxMpConfigStorage;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        wxMpConfigStorage = new WxMpInMemoryConfigStorage();
        wxMpConfigStorage.setAppId(Constant.APPID);
        wxMpConfigStorage.setSecret(Constant.SECRETS);
        wxMpConfigStorage.setToken(Constant.TOKEN);
        wxMpConfigStorage.setAesKey(Constant.AESKEY);
        wxMpConfigStorage.setPartnerId(Constant.MCH_ID);
        wxMpConfigStorage.setPartnerKey(Constant.MCH_KEY);
        wxService = new WxMpServiceImpl();
        wxService.setWxMpConfigStorage(wxMpConfigStorage);

    }

}
